home *** CD-ROM | disk | FTP | other *** search
- Path: news.flex.com.au!news
- From: cobweb@flex.com.au (Tony L)
- Newsgroups: comp.lang.c++
- Subject: Help Please
- Date: Sat, 30 Mar 1996 03:48:03 GMT
- Organization: Flex Information Technology
- Message-ID: <4ji7eo$kgm@daisy.flex.com.au>
- NNTP-Posting-Host: slip1-8.flex.com.au
- X-Newsreader: Forte Free Agent 1.0.82
-
- Hi all,
-
- I have this prog that I can't get to do a simple IF condition
- properly. I just want it to say "You have voted for Paul Keating" if
- the user enters Paul Keating. Yeah! I know, stupid idea for a
- program :-)))
-
- When I enter Paul Keating or not, it says "You didn't vote for Paul
- Keating" even if I did enter "Paul Keating"
-
- Could someone please help me with it....
-
- it is as follows:
-
- #include <conio.h>
- #include <stdio.h>
-
- main()
- {
- int age;
- int yrs;
- char him[] = "Keating";
- char first[15], last[15];
- char first2[15], last2[15];
-
- clrscr();
- printf(" The Voting Booth!");
- printf("\n\nWhat is your first name please? ");
- scanf(" %s", first);
- printf("\nWhat is your last name please? ");
- scanf(" %s", last);
-
- printf("\nHow old are you please? ");
- scanf(" %d", &age);
- if (age < 18)
- { printf("You are too YOUNG to vote!!!!\n\a\a\a");
- yrs = 18 - age;
- printf("You can vote in %d years.\n", yrs); }
- else
- { printf("\nCongratulations! you are old enough to vote!\n"); }
- printf("\nWho would you like to vote for? ");
- printf("\n\nWhat is their first name please? ");
- scanf(" %s", first2);
- printf("\nWhat is their last name please? ");
- scanf(" %s", last2);
- if (last2 == him)
- { printf("you have voted for Paul Keating!"); }
- else
- { printf("\nYou didn't vote for Paul Keating!"); }
-
- printf("\n\nHere is the Info you entered:\n\n");
- printf("Name: %s %s\n", first, last);
- printf("Age: %d", age);
- printf("\nYou Voted for: %s %s\n", first2, last2);
- return 0;
- }
-
- Thank you very much for your time....
-
-
- Ciao,
- TonyL....
-
- *---------------------------------*
- E-mail: cobweb@flex.com.au
- lamborghini@acslink.net.au
- URL: http://www.peg.apc.org/~lamborghini
- Mobile: 0419 255 830 +61 419 255 830
- *-------------------------------------------*
-
-